#ifndef RT_TrialLicense_H
#define RT_TrialLicense_H



#include "RtBase.h"
#include "RtTimerWrapper.h"


typedef enum {
	WCR_REGISTERED_TIME_VALID = 0,
	WCR_REGISTERED_TIME_INVALID = 1,
	WCR_UNABLE_GET_HARDINFO = 2,
	WCR_UNREGISTERED = 3,
	WCR_UNCHECK = 4,
	WCR_OVER_MAX_COUNT = 5
}RT_TrialLicense_CHECK_RESULT;

class RT_API_EXPORT CRtTrialLicense : public CRtTimerWrapperSink
{
public:
	CRtTrialLicense();
	virtual ~CRtTrialLicense();

public:

	RT_TrialLicense_CHECK_RESULT Initialize(const CRtString& inLicenceCode);
	
	RtResult CheckEnableConference(WORD inNumber);

	RtResult Release();

public:
#ifdef RT_WIN32
	DWORD64 GetSerialNo();
#else
	unsigned long long GetSerialNo();
#endif
	
	RtResult GetLicenseCode(const CRtString& a, char * b,
								const CRtString& c,const CRtString& d);




	RT_TrialLicense_CHECK_RESULT GetLicenseType(){return m_licence;}
	const CRtString& GetExpireTime(const CRtString& inCode);
	const CRtString& GetMaxNumber(const CRtString& inCode);

	const CRtString& GetBoxLicenseInfo(const CRtString& inCode);


public :
	//CRtTimerWrapperSink
	virtual void OnTimer(CRtTimerWrapper* inId);


private:
	RT_TrialLicense_CHECK_RESULT GetCurrentLicenceType(){return m_licence;}
	WORD GetEnableNumber(){return m_enableNumber;}

	const CRtString& GetEncodeStream(unsigned char * inContent, const CRtString& inKey, DWORD inStreamLength);
	const CRtString& GetDecodeStream(unsigned char * inContent, const CRtString& inKey, DWORD inStreamLength);


	const CRtString& GetDecodeSerial(const CRtString& inContent, const CRtString& inKey);
	const CRtString& GetEncodeSerial(const CRtString& inContent, const CRtString& inKey);

	RT_TrialLicense_CHECK_RESULT GetTrialLicenseType();

	/*void CRtTrialLicense::test();*/

	RtResult SaveLicenceToFile();
	
	RtResult SaveLicenceToFile(
		const CRtString& inSerialFile, 
		const CRtString& inLicenceFile,
		const CRtString& inTimeString,
		const CRtString& inNumberString);

private:
	CRtString m_serialNo;
	CRtString m_timeSetting;
	//std::vector<CRtString> m_realMacAddrList;
	RT_TrialLicense_CHECK_RESULT m_licence;
	CRtTimerWrapper	m_timer;
	time_t m_leastTime;
	WORD m_enableNumber;
	CRtString m_staticString;
};

#ifdef RT_WIN32
int __stdcall DoJob(char * a, char * b, char * c, char * d);
#endif

#endif //RT_TrialLicense_H

